package com.gao.alg;

import java.util.Arrays;

/**
 * @author gao
 * @date 2023/12/08 11:18:09
 */
public class ShellSort {
    private static void shellSort(int[] arr) {
        for (int inc = arr.length / 2; inc > 0; inc /= 2) {
            for (int i = inc; i < arr.length; i++) {
                for (int j = i; j >= inc; j -= inc) {
                    if (arr[j] < arr[j - inc]) {
                        int t = arr[j];
                        arr[j] = arr[j - inc];
                        arr[j - inc] = t;
                    } else {
                        break;
                    }
                }
            }
        }
    }

    public static void main(String[] args) {
        int[] arr = {50, 19, 1, 10, 2, 88, 3, -7, 4, 6, 10};
        shellSort(arr);
        System.out.println(Arrays.toString(arr));
    }
}
